package com.wswy.wzcx.widget.drawable;

import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.support.annotation.Nullable;

public abstract class BaseDrawable extends Drawable {

  protected Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);

  protected Rect rect = new Rect();

  @Override
  protected void onBoundsChange(Rect bounds) {
    super.onBoundsChange(bounds);
    rect.set(bounds);
  }

  @Override
  public void setAlpha(int alpha) {
    paint.setAlpha(alpha);
  }

  @Override
  public void setColorFilter(@Nullable ColorFilter colorFilter) {
    paint.setColorFilter(colorFilter);
  }

  @Override
  public int getOpacity() {
    return PixelFormat.TRANSLUCENT;
  }

  @Override
  public int getIntrinsicHeight() {
    return rect.height();
  }

  @Override
  public int getIntrinsicWidth() {
    return rect.width();
  }
}
